<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<META HTTP-EQUIV="pragma" CONTENT="no-cache">
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
		<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 
		<META HTTP-EQUIV="expires" CONTENT="0">
			
		<title>真人CS吃鸡后台管理系统 </title>
		<link rel="stylesheet" href="../../css/login.css" media="all">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
	</head>
	<body>
		<div id="particles">
		      
		        <form class="login-body layui-form" id="form">
		            <div class="login-title">
		                真人CS吃鸡后台管理系统
		            </div>
		            <div class="login-item">
		                <label class="layui-icon layui-icon-username"></label>
		                <input type="text" name="userName"  required  lay-verify="required" class="layui-input" placeholder="用户名" />
		            </div>
		            <div class="login-item">
		                <label class="layui-icon layui-icon-password"></label>
		                <input type="password" name="password" required  lay-verify="required" class="layui-input" placeholder="密码" />
		            </div>
		            <div class="login-item">
		                <div class="layui-inline" style="width:210px;">
		                    <label class="layui-icon layui-icon-auz"></label>
		                    <input type="text"  id="validateCode" name="validateCode" lay-verify="required"
							  class="layui-input" placeholder="验证码" />
		                </div>
		                <div class="layui-inline">
		                    <img id="imgCode"  class="imgcode" alt="点击切换验证码" title="点击切换验证码" onclick="changeCode()" />
		                </div>
		            </div>
		            <div class="login-item">
		                <button class="layui-btn layui-btn-fluid" class="layui-btn" lay-submit lay-filter="loginform">登  录</button>
		            </div>
		        </form>
		    </div>
			
			<script src="../../js/common.js"></script>
			<script src="../../lib/jquery-3.3.1.min.js"></script>
			<script src="../../lib/jquery.particleground.min.js"></script> 
			<script src="../../layui/layui.js"></script>
			<script src="../../js/login.js"></script>
			<script src="../../js/BrowserCheck.js"></script>
		
			<script>
				
				var setter;
				layui.config({
				  base: '../layuiadmin/' //静态资源所在路径
				}).extend({
				  index: 'lib/index' //主入口模块
				}).use('index',function()
				{
					var $ = layui.$;
					setter = layui.setter;
					changeCode();
				});
				
			
				layui.use('form', function(){
				  var form = layui.form;
				  //监听提交
				  form.on('submit(loginform)', function(data){
					 var userName= data.field["userName"];
					 var password = data.field["password"];
					var postUrl = setter.prefixUrl+"AdminLogin"+"/"+userName+"/"+password+"/123456";
					$("button").text("登录中...");
					$("button").attr("disabled","isDisabled");
					$.post(postUrl, data.field,
					          function(data){
								
								  //验证码错误
									if(data!="")
									{
										SetCookie("Admin_ID",data.id);
										SetCookie("Admin_Name",data.name);
										$("button").text("登入成功，页面跳转中...");
										layer.msg('登入成功，页面跳转中...', {
										  offset: '15px'
										  ,icon: 1
										  ,time: 1000
										}, function(){
										  location.href = 'index.html'; 
										});
										
									}
									
									else 
									{
										layer.alert("账号或者密码错误");
										$("button").text("登 录");
										$("button").removeAttr("disabled");
										changeCode();
									}
					          });
							  
							  
					return false;
				    
				  });
				});
				
				
				function changeCode()
				{
					$("#validateCode").val("");
					$("#imgCode").attr("src", "https://www.oschina.net/action/user/captcha?time=" + Math.random());
				}
				
				function GetCookie(NameOfCookie)
				{
					
					if (document.cookie.length > 0) {
						begin = document.cookie.indexOf(NameOfCookie + "=");
						if (begin !== -1) {
							begin += NameOfCookie.length + 1;
							end = document.cookie.indexOf(";", begin);
							if (end === -1) end = document.cookie.length;
							return unescape(document.cookie.substring(begin, end));
						}
					}
					 return null;
					          
				}
			</script>
			
	</body>
</html>
